<template>
<div>
  <div style='margin-bottom: 20px'>
    <a>请提出您的宝贵意见</a>
  </div>
  <el-input
    v-model="param.message"
    :rows="8"
    type="textarea"
    placeholder="Please input"
  />
  <div style='margin-top: 40px '>
    <el-button type="danger" @click='resetvalue'>重置</el-button>
    <el-button type="primary" @click='addopinion'>提交</el-button>
  </div>
</div>
</template>

<script  setup>
import { toRefs, reactive, onBeforeMount,ref,getCurrentInstance } from 'vue'
import user from '@/store/modules/user'
import { addopinions } from '@/api/user'
let { proxy } = getCurrentInstance();
import { ElMessage } from 'element-plus'


const param = reactive({
  message:'',
  userId:"",
  username:""
})

const resetvalue = ()=>{
  proxy.param.message= null
}

const addopinion =()=>{
  let user = JSON.parse(sessionStorage.getItem("user"));
  param.userId=user.id+''
  param.username = user.usernamezh
  console.log(param)
  addopinions(param).then((response=>{
    debugger;
    if(response.code == 200){
      ElMessage({
        message: '新增成功',
        type: 'success',
      })
      proxy.param.message= null

    }else{
      ElMessage.error('新增失败')
    }
  }))
}
</script>

<style scoped>

</style>
